void processCmd(char inByte) {
  if (inByte > 31) {   // We won't process control characters
    switch (inByte)  {
      
      case '1':  // turns on/off FET switch 1
      {
        if (arm_mode) {
          if (fet1_on) {
            fet1_on = false;
            digitalWrite(fet1Pin, LOW);
          }
          else {
            fet1_on = true;
            digitalWrite(fet1Pin, HIGH);
            fet1_timeout = millis() + fet_time;
          }
          osc.sendCmd(ack);
        }
        else {
          osc.sendCmd(nak);
        }
        break;
      }
      
      case '2':  // turns on/off FET switch 2
      {
        if (arm_mode) {
          if (fet2_on) {
            fet2_on = false;
            digitalWrite(fet2Pin, LOW);
          }
          else {
            fet2_on = true;
            digitalWrite(fet2Pin, HIGH);
            fet2_timeout = millis() + fet_time;
          }
          osc.sendCmd(ack);;
        }
        else {
          osc.sendCmd(nak);;
        }
        break;
      }
      
      case 'A': // arm - arms fet switches in test mode
      {
        if (test_mode) {
          arm_mode = true;
          osc.sendCmd(ack);
        }
        else {
          osc.sendCmd(nak);
        }
        break;
      }
      
      case 'a': // alt - set deploy altitude
      {
        h_deploy = osc.iPop();
        write_EEPROM(EE_DPLY, h_deploy);
        osc.sendCmd(ack);
        break;
      }
      
      case 'c':  // close - closes main pin
      {
        chute_servo.write(CHUTE_CLOSED);
        chute_open = false;
        osc.sendCmd(ack);
        break;
      }
      
      case 'D': { // Data - sends Status Data Message
        String s = "";
        statusStr(&s);
        osc.sendString(sts_str, s);
        break;
      }
        
      case 'd': { // data - sends sensor data
        String s = "";
        sensorStr(&s);
        osc.sendString(data_str, s);
        break;
      }
        
      case 'E':  // ejection - turns on/off primary ejection
      {
        if (do_deploy) {
          do_deploy = false;
        }
        else {
          do_deploy = true;
        }
        osc.sendByte(dep_str, do_deploy);
        EEPROM.write(EE_DEP1, do_deploy);
        break;
      }
      
      case 'e': { // elevation - set site elevation
        site_alt = osc.iPop();
        write_EEPROM(EE_SITE, site_alt);
        osc.sendCmd(ack);
        break;
      }
      
      case 'F':  // Send Flight Data
      {
        String s = "";
        flightStr(&s);
        osc.sendString(flight_str, s);
        break;
      }
      
      case 'f':  // file annotation
      {
        if (do_record) {
          sd.println(osc.dataString);
        } else {
          fString = osc.dataString;
        }
        break;
      }
      
      case 'G':  // Go for deploy altitude
      {
        h_launch = osc.iPop();
        write_EEPROM(EE_HSTG, h_launch);
        osc.sendCmd(ack);
        break;
      }
      case 'h':  // h - enables/disables launch hold
      {
        if (launch_hold) {
          launch_hold = false;
        } else {
          launch_hold = true;
          if (mode == pre_launch) {
            mode = start_mode;
            do_record = false;
          }
        }
        break;
      }
      
      case ack_str:  // (case 'K': acK - send ack heartbeat
      {
        osc.sendCmd(ack);
        break;
      }
      
      case 'L': { // flight - forces cal & flight mode - if continuity OK
        if (fet_go && !launch_hold) {
          mode = calibrate;
          osc.sendCmd(ack);
         } else {
          osc.sendCmd(nak);
         }
       break;  
      }

      case 'm':  // main - turns on/off main chute deployment
      {
        if (do_main) {
          do_main = false;
        }
        else {
          do_main = true;
        }
        EEPROM.write(EE_DEP2,do_main);
        osc.sendByte(main_str, do_main);
        break;
      }
      
      case 'o':  // open - opens main pin
      {
        chute_servo.write(CHUTE_OPEN);
        chute_open = true;
        osc.sendCmd(ack);
        break;
      }
            
      case 'p':  // Send Flight Settings
      {
        String s = "";
        settingsStr(&s);
        osc.sendString(set_str, s);
        break;
      }
      
      case 'r':  // record - starts and stops recording in test mode
      {
        if (test_mode && do_record) {
          do_record = false;
          sd.close();
          file_open = false;
          osc.sendCmd(ack);
        } else if (test_mode) {
          if (!file_open) {
            sd.open();
            file_open = true;
          }
          sd.println(fString);
          do_record = true;
          osc.sendCmd(ack);
        } else {
          osc.sendCmd(nak);
        }
        break;
      }
      
      case 'S':  // stage - turns on/off staging
      {
        if (do_stage) {
          do_stage = false;
        }
        else {
          do_stage = true;
        }
        EEPROM.write(EE_2STG, do_stage);
        osc.sendByte(stg_str, do_stage);
        break;
      }
      
      case 's': { // stage elevation - set minimum staging elevation
        h_stage = osc.iPop();
        write_EEPROM(EE_HSTG, h_stage);
        osc.sendCmd(ack);
        break;
      }
      
      case 't':  //test - turns test mode on & off
      {
        if ((mode == start_mode) || (mode == post_flight)) {
          test_mode = !test_mode;
          if (!test_mode) {
            arm_mode = false;
            fet1_on = false;
            digitalWrite(fet1Pin, LOW);
            fet2_on = false;
            digitalWrite(fet2Pin, LOW);
            if (do_record) {
              do_record = false;
              sd.close();
            }
          }
        }
        osc.sendByte(test_str, test_mode);
        break;
      }
      
      case 'v': { // stage velocity - set minimum staging velocity
        v_stage = osc.iPop();
        write_EEPROM(EE_VSTG, v_stage);
        osc.sendCmd(ack);
        break;
      }
      
       case 'x':  // x-safe - turns off arm mode
       {
         fet1_on = false;
         digitalWrite(fet1Pin, LOW);
         fet2_on = false;
         digitalWrite(fet2Pin, LOW);
         arm_mode = false;
         osc.sendCmd(ack);
         break;
       }
       
       default:
        osc.sendCmd(nak);
    }
  }
}
